home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Python 1.4 / Python 1.4 source / Mac / Tools / BBPy / source / BB-stuff / ExternalInterface.h
Encoding:
C/C++ Source or Header  |  1996-09-16  |  23.7 KB  |  717 lines  |  [TEXT/CWIE]

  1. #pragma once
  2.  
  3. #include <MixedMode.h>
  4. #include <Dialogs.h>
  5. #include <Files.h>
  6. #include <Windows.h>
  7. #include <AppleEvents.h>
  8. #include <StandardFile.h>
  9.  
  10. #if defined(powerc) || defined (__powerc)
  11. #pragma options align=mac68k
  12. #endif
  13.  
  14. typedef struct
  15. {
  16.     FSSpec    spec;    //    designates file on disk
  17.     long    key;    //    reserved for future expansion
  18.  
  19.     char    tree;    //    0 for absolute, 1 for project, 2 for system
  20.     Boolean    found;    //    FALSE if file couldn't be located; if so, all other info is moot
  21.  
  22.     OSType    type;    //    file type of found file
  23.     OSType    crtr;    //    signature of found file's creator
  24.     
  25.     short    spare0;    //    reserved for future expansion
  26.     long    spare1;
  27. } ProjectEntry;
  28.  
  29. enum
  30. {
  31.     kNeitherTree,
  32.     kProjectTree,
  33.     kSystemTree
  34. };
  35.  
  36. enum
  37. {
  38.     kTHINKCProject,
  39.     kTHINKPascalProject,
  40.     kCodeWarriorProject
  41. };
  42.  
  43. //    masks for the "flags" argument to new-convention interfaces
  44.  
  45. #define xfWindowOpen        0x00000001
  46. #define xfWindowChangeable    0x00000002
  47. #define xfHasSelection        0x00000004
  48. #define xfUseDefaults        0x00000008
  49. #define xfIsBBEditLite        0x00000040
  50. #define xfIsBBEditDemo        0x00000080
  51.  
  52. typedef struct
  53. {
  54.     FSSpec    spec;
  55.     OSType    key;
  56.     
  57.     short    error_kind;
  58.     long    line_number;
  59.     
  60.     Str255    message;
  61. } ErrorEntry;
  62.  
  63. typedef enum
  64. {
  65.     kNote    = 0,
  66.     kError,
  67.     kWarning
  68. } ErrorKind;
  69.  
  70. #define kCurrentExternalVersion        5    //    current version of callbacks
  71.  
  72. //    Universal callback interfaces
  73.  
  74. #if USESROUTINEDESCRIPTORS
  75.  
  76. #define ExtensionUPPInfo (kPascalStackBased \
  77.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ExternalCallbackBlock *))) \
  78.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(WindowPtr))))
  79.  
  80. #define NewExtensionUPPInfo (kPascalStackBased \
  81.                             | RESULT_SIZE(SIZE_CODE(sizeof(OSErr))) \
  82.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ExternalCallbackBlock *))) \
  83.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(WindowPtr))) \
  84.                             | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long))) \
  85.                             | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(AppleEvent *))) \
  86.                             | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(AppleEvent *))))
  87.  
  88. #define GetWindowContentsUPPInfo (kPascalStackBased \
  89.                             | RESULT_SIZE(SIZE_CODE(sizeof(Handle))) \
  90.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowPtr))))
  91.                             
  92. #define GetSelectionUPPInfo (kPascalStackBased \
  93.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long *))) \
  94.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long *))) \
  95.                             | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long *))))
  96.                             
  97. #define SetSelectionUPPInfo (kPascalStackBased \
  98.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))) \
  99.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))) \
  100.                             | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long))))
  101.  
  102. #define GetDocInfoUPPInfo (kPascalStackBased \
  103.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowPtr))) \
  104.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(unsigned char *))) \
  105.                             | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short *))) \
  106.                             | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long *))))
  107.  
  108. #define GetModDateUPPInfo (kPascalStackBased \
  109.                             | RESULT_SIZE(SIZE_CODE(sizeof(long))) \
  110.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowPtr))))
  111.                             
  112. #define CopyUPPInfo (kPascalStackBased \
  113.                             | RESULT_SIZE(SIZE_CODE(sizeof(Handle))))
  114.                             
  115. #define PasteUPPInfo (kPascalStackBased \
  116.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Handle))))
  117.                             
  118. #define GetLastLineUPPInfo (kPascalStackBased | RESULT_SIZE(SIZE_CODE(sizeof(long))))
  119.  
  120. #define GetLineNumberUPPInfo (kPascalStackBased \
  121.                             | RESULT_SIZE(SIZE_CODE(sizeof(long))) \
  122.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))))
  123.                             
  124. #define GetLineStartUPPInfo (kPascalStackBased \
  125.                             | RESULT_SIZE(SIZE_CODE(sizeof(long))) \
  126.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))))
  127.                             
  128. #define GetLineEndUPPInfo (kPascalStackBased \
  129.                             | RESULT_SIZE(SIZE_CODE(sizeof(long))) \
  130.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))))
  131.  
  132. #define GetLinePosUPPInfo (kPascalStackBased \
  133.                             | RESULT_SIZE(SIZE_CODE(sizeof(long))) \
  134.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))))
  135.  
  136. #define InsertUPPInfo (kPascalStackBased \
  137.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(char *))) \
  138.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))))
  139.                             
  140. #define DeleteUPPInfo (kPascalStackBased)
  141.  
  142. #define SetWindowContentsUPPInfo (kPascalStackBased \
  143.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowPtr))) \
  144.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle))))
  145.                             
  146. #define ContentsChangedUPPInfo (kPascalStackBased \
  147.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(WindowPtr))))
  148.                             
  149. #define GetFileTextUPPInfo (kPascalStackBased \
  150.                             | RESULT_SIZE(SIZE_CODE(sizeof(Handle))) \
  151.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short))) \
  152.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))) \
  153.                             | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(unsigned char *))) \
  154.                             | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(Boolean *))))
  155.                             
  156. #define GetFolderUPPInfo (kPascalStackBased \
  157.                             | RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
  158.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned char *))) \
  159.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short *))) \
  160.                             | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long *))))
  161.                             
  162. #define OpenSeveralUPPInfo (kPascalStackBased \
  163.                             | RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
  164.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Boolean))) \
  165.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short *))) \
  166.                             | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(StandardFileReply ***))))
  167.                             
  168. #define CenterDialogUPPInfo (kPascalStackBased \
  169.                             | RESULT_SIZE(SIZE_CODE(sizeof(DialogPtr))) \
  170.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short))))
  171.                             
  172. #define StandardFilterUPPInfo uppModalFilterProcInfo
  173.                             
  174. #define FrameDialogItemUPPInfo uppUserItemProcInfo
  175.  
  176. #define NewDocumentUPPInfo    (kPascalStackBased \
  177.                             | RESULT_SIZE(SIZE_CODE(sizeof(WindowPtr))))
  178.                             
  179. #define OpenDocumentUPPInfo    (kPascalStackBased \
  180.                             | RESULT_SIZE(SIZE_CODE(sizeof(WindowPtr))))
  181.                             
  182. #define AllocateUPPInfo        (kPascalStackBased \
  183.                             | RESULT_SIZE(SIZE_CODE(sizeof(Handle))) \
  184.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))) \
  185.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Boolean))))
  186.                             
  187. #define FindPatternUPPInfo    (kPascalStackBased \
  188.                             | RESULT_SIZE(SIZE_CODE(sizeof(long))) \
  189.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(char *))) \
  190.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))) \
  191.                             | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long))) \
  192.                             | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(char *))) \
  193.                             | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long))) \
  194.                             | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(Boolean))))
  195.  
  196. #define ReportOSErrorUPPInfo    (kPascalStackBased)
  197.  
  198. #define GetPreferenceUPPInfo (kPascalStackBased \
  199.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ResType))) \
  200.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short))) \
  201.                             | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(void *))) \
  202.                             | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short *))))
  203.                             
  204. #define SetPreferenceUPPInfo (kPascalStackBased \
  205.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ResType))) \
  206.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short))) \
  207.                             | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(void *))) \
  208.                             | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short *))))
  209.  
  210. #define StartProgressUPPInfo (kPascalStackBased \
  211.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned char *))) \
  212.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))) \
  213.                             | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Boolean))))
  214.                             
  215. #define DoProgressUPPInfo    (kPascalStackBased \
  216.                             | RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
  217.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))))
  218.  
  219. #define DoneProgressUPPInfo    (kPascalStackBased)
  220.  
  221. #define GetProjectListUPPInfo (kPascalStackBased \
  222.                             | RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
  223.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(FSSpec *))) \
  224.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short *))) \
  225.                             | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short *))) \
  226.                             | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(ProjectEntry***))))
  227.                             
  228. #define ProjectTextListUPPInfo (kPascalStackBased \
  229.                             | RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
  230.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(FSSpec *))) \
  231.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle *))))
  232.  
  233. #define PresetUndoUPPInfo    (kPascalStackBased \
  234.                             | RESULT_SIZE(SIZE_CODE(sizeof(Boolean))))
  235.                             
  236. #define SetUndoUPPInfo        (kPascalStackBased)
  237.  
  238. #define OpenFileUPPInfo        (kPascalStackBased \
  239.                             | RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
  240.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(FSSpec *))) \
  241.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(WindowPtr *))))
  242.  
  243. #define PrepareUndoUPPInfo    (kPascalStackBased \
  244.                             | RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
  245.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))) \
  246.                             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(long))) \
  247.                             | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(long))) \
  248.                             | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long))))
  249.                             
  250. #define CommitUndoUPPInfo    (kPascalStackBased \
  251.                             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long))))
  252.  
  253. #define CreateResultsUPPInfo    (kPascalStackBased \
  254.                                 | RESULT_SIZE(SIZE_CODE(sizeof(Boolean))) \
  255.                                 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(unsigned char *))) \
  256.                                 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short))) \
  257.                                 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Handle))) \
  258.                                 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(WindowPtr *))))
  259.                             
  260. typedef    UniversalProcPtr    GetWindowContentsProc;
  261. typedef    UniversalProcPtr    GetSelectionProc;
  262. typedef    UniversalProcPtr    SetSelectionProc;
  263. typedef    UniversalProcPtr    GetDocInfoProc;
  264. typedef    UniversalProcPtr    GetModDateProc;
  265. typedef    UniversalProcPtr    CopyProc;
  266. typedef    UniversalProcPtr    PasteProc;
  267.     
  268. typedef    UniversalProcPtr    GetLastLineProc;
  269. typedef    UniversalProcPtr    GetLineNumberProc;
  270. typedef    UniversalProcPtr    GetLineStartProc;
  271. typedef    UniversalProcPtr    GetLineEndProc;
  272. typedef    UniversalProcPtr    GetLinePosProc;
  273.     
  274. typedef    UniversalProcPtr    InsertProc;
  275. typedef    UniversalProcPtr    DeleteProc;
  276.     
  277. typedef    UniversalProcPtr    SetWindowContentsProc;
  278. typedef    UniversalProcPtr    ContentsChangedProc;
  279.     
  280. typedef    UniversalProcPtr    GetFileTextProc;
  281.  
  282. typedef    UniversalProcPtr    GetFolderProc;
  283. typedef    UniversalProcPtr    OpenSeveralProc;
  284.     
  285. typedef    UniversalProcPtr    CenterDialogProc;
  286. typedef    UniversalProcPtr    StandardFilterProc;
  287. typedef    UniversalProcPtr    FrameDialogItemProc;
  288.     
  289. typedef    UniversalProcPtr    NewDocumentProc;
  290. typedef    UniversalProcPtr    OpenDocumentProc;
  291.  
  292. typedef    UniversalProcPtr    AllocateProc;
  293. typedef    UniversalProcPtr    FindPatternProc;
  294.     
  295. typedef    UniversalProcPtr    ReportOSErrorProc;
  296.     
  297. typedef    UniversalProcPtr    GetPreferenceProc;
  298. typedef    UniversalProcPtr    SetPreferenceProc;
  299.  
  300. typedef    UniversalProcPtr    StartProgressProc;
  301. typedef    UniversalProcPtr    DoProgressProc;
  302. typedef    UniversalProcPtr    DoneProgressProc;
  303.     
  304. typedef    UniversalProcPtr    GetProjectListProc;
  305. typedef    UniversalProcPtr    ProjectTextListProc;
  306.         
  307. typedef    UniversalProcPtr    PresetUndoProc;
  308. typedef    UniversalProcPtr    SetUndoProc;
  309.     
  310. typedef    UniversalProcPtr    OpenFileProc;
  311.  
  312. typedef UniversalProcPtr    PrepareUndoProc;
  313. typedef UniversalProcPtr    CommitUndoProc;
  314.  
  315. typedef UniversalProcPtr    CreateResultsProc;
  316.  
  317. #define CallGetWindowContents(proc, w) \
  318.     (Handle)(CallUniversalProc(proc, GetWindowContentsUPPInfo, (w)))
  319.     
  320. #define CallGetSelection(proc, selStart, selEnd, firstChar) \
  321.     (CallUniversalProc(proc, GetSelectionUPPInfo, (selStart), (selEnd), (firstChar)))
  322.     
  323. #define CallSetSelection(proc, selStart, selEnd, firstChar) \
  324.     (CallUniversalProc(proc, SetSelectionUPPInfo, (selStart), (selEnd), (firstChar)))
  325.     
  326. #define CallGetDocInfo(proc, w, name, vRefNum, dirID) \
  327.     (CallUniversalProc(proc, GetDocInfoUPPInfo, (w), (name), (vRefNum), (dirID)))
  328.     
  329. #define CallGetModDate(proc, w) \
  330.     (CallUniversalProc(proc, GetModDateUPPInfo, (w)))
  331.     
  332. #define CallCopy(proc) \
  333.     (Handle)(CallUniversalProc(proc, CopyUPPInfo))
  334.     
  335. #define CallPaste(proc, h) \
  336.     (CallUniversalProc(proc, PasteUPPInfo, (h)))
  337.     
  338. #define CallGetLastLine(proc) \
  339.     (CallUniversalProc(proc, GetLastLineUPPInfo))
  340.     
  341. #define CallGetLineNumber(proc, sel) \
  342.     (CallUniversalProc(proc, GetLineNumberUPPInfo, (sel)))
  343.     
  344. #define CallGetLineStart(proc, sel) \
  345.     (CallUniversalProc(proc, GetLineStartUPPInfo, (sel)))
  346.  
  347. #define CallGetLineEnd(proc, sel) \
  348.     (CallUniversalProc(proc, GetLineEndUPPInfo, (sel)))
  349.  
  350. #define CallGetLinePos(proc, sel) \
  351.     (CallUniversalProc(proc, GetLinePosUPPInfo, (sel)))
  352.  
  353. #define CallInsert(proc, text, len) \
  354.     (CallUniversalProc(proc, InsertUPPInfo, (text), (len)))
  355.     
  356. #define CallDelete(proc) \
  357.     (CallUniversalProc(proc, DeleteUPPInfo))
  358.     
  359. #define CallSetWindowContents(proc, w, h) \
  360.     (CallUniversalProc(proc, SetWindowContentsUPPInfo, (w), (h)))
  361.     
  362. #define CallContentsChanged(proc, w) \
  363.     (CallUniversalProc(proc, ContentsChangedUPPInfo, (w)))
  364.     
  365. #define CallGetFileText(proc, vRefNum, dirID, name, canDispose) \
  366.     (Handle)(CallUniversalProc(proc, GetFileTextUPPInfo, (vRefNum), (dirID), (name), (canDispose)))
  367.     
  368. #define CallGetFolder(proc, prompt, vRefNum, dirID) \
  369.     (Boolean)(CallUniversalProc(proc, GetFolderUPPInfo, (prompt), (vRefNum), (dirID)))
  370.     
  371. #define CallOpenSeveral(proc, sort, file_count, files) \
  372.     (Boolean)(CallUniversalProc(proc, OpenSeveralUPPInfo, (sort), (file_count), (files)))
  373.     
  374. #define CallCenterDialog(proc, dialogID) \
  375.     (DialogPtr)(CallUniversalProc(proc, CenterDialogUPPInfo, (dialogID)))
  376.     
  377. #define CallStandardFilter(proc, d, event, item) \
  378.     CallModalFilterProc(proc, (d), (event), (item))
  379.  
  380. #define CallFrameDialogItem(proc, d, item) \
  381.     CallUserItemProc(proc, (d), (item))
  382.     
  383. #define CallNewDocument(proc) \
  384.     (WindowPtr)(CallUniversalProc(proc, NewDocumentUPPInfo))
  385.     
  386. #define CallOpenDocument(proc) \
  387.     (WindowPtr)(CallUniversalProc(proc, OpenDocumentUPPInfo))
  388.     
  389. #define CallAllocate(proc, size, clear) \
  390.     (Handle)(CallUniversalProc(proc, AllocateUPPInfo, (size), (clear)))
  391.     
  392. #define CallFindPattern(proc, text, text_len, text_offset, pat, pat_len, case_sens) \
  393.     (CallUniversalProc(proc, FindPatternUPPInfo, (text), (text_len), (text_offset), \
  394.                         (pat), (pat_len), (case_sens)))
  395.                         
  396. #define CallReportOSError(proc, code) \
  397.     (CallUniversalProc(proc, ReportOSErrorUPPInfo, (code)))
  398.     
  399. #define CallGetPreference(proc, prefType, req_len, buffer, act_len) \
  400.     (CallUniversalProc(proc, GetPreferenceUPPInfo, (prefType), (req_len), (buffer), (act_len)))
  401.     
  402. #define CallSetPreference(proc, prefType, req_len, buffer, act_len) \
  403.     (CallUniversalProc(proc, SetPreferenceUPPInfo, (prefType), (req_len), (buffer), (act_len)))
  404.  
  405. #define CallStartProgress(proc, str, total, cancel_allowed) \
  406.     (CallUniversalProc(proc, StartProgressUPPInfo, (str), (total), (cancel_allowed)))
  407.     
  408. #define CallDoProgress(proc, done) \
  409.     (Boolean)(CallUniversalProc(proc, DoProgressUPPInfo, (done)))
  410.     
  411. #define CallDoneProgress(proc) \
  412.     (CallUniversalProc(proc, DoneProgressUPPInfo))
  413.     
  414. #define CallGetProjectList(proc, spec, kind, count, entries) \
  415.     (Boolean)(CallUniversalProc(proc, GetProjectListUPPInfo, (spec), (kind), (count), (entries)))
  416.     
  417. #define CallProjectTextList(proc, spec, text) \
  418.     (Boolean)(CallUniversalProc(proc, ProjectTextListUPPInfo, (spec), (text)))
  419.     
  420. #define CallPresetUndo(proc) \
  421.     (Boolean)(CallUniversalProc(proc, PresetUndoUPPInfo))
  422.     
  423. #define CallSetUndo(proc) \
  424.     (CallUniversalProc(proc, SetUndoUPPInfo))
  425.     
  426. #define CallOpenFile(proc, spec, w) \
  427.     (Boolean)(CallUniversalProc(proc, OpenFileUPPInfo, (spec), (w)))
  428.  
  429. #define CallPrepareUndo(proc, undo_start, undo_end, sel_start, sel_end) \
  430.     (Boolean)(CallUniversalProc(proc, PrepareUndoUPPInfo, (undo_start), (undo_end), \
  431.                                 (sel_start), (sel_end)))
  432.                                 
  433. #define CallCommitUndo(proc, new_end) \
  434.     (CallUniversalProc(proc, CommitUndoUPPInfo, (new_end)))
  435.  
  436. #define CallCreateResults(proc, title, count, results, w) \
  437.     (Boolean)(CallUniversalProc(proc, CreateResultsUPPInfo, (title), (count), (results), (w)))
  438.     
  439. #else
  440.  
  441. typedef pascal    Handle    (*GetWindowContentsProc)(WindowPtr w);
  442. typedef    pascal    void    (*GetSelectionProc)(long *selStart, long *selEnd, long *firstChar);
  443. typedef    pascal    void    (*SetSelectionProc)(long selStart, long selEnd, long firstChar);
  444. typedef    pascal    void    (*GetDocInfoProc)(WindowPtr w, Str255 fName, short *vRefNum, long *dirID);
  445. typedef    pascal    long    (*GetModDateProc)(WindowPtr w);
  446. typedef    pascal    Handle    (*CopyProc)(void);
  447. typedef    pascal    void    (*PasteProc)(Handle pasteText);
  448.     
  449. typedef    pascal    long    (*GetLastLineProc)(void);
  450. typedef    pascal    long    (*GetLineNumberProc)(long selection);
  451. typedef    pascal    long    (*GetLineStartProc)(long selection);
  452. typedef    pascal    long    (*GetLineEndProc)(long selection);
  453. typedef    pascal    long    (*GetLinePosProc)(long line);
  454.     
  455. typedef    pascal    void    (*InsertProc)(char *text, long len);
  456. typedef    pascal    void    (*DeleteProc)(void);
  457.     
  458. typedef    pascal    void    (*SetWindowContentsProc)(WindowPtr w, Handle h);
  459. typedef    pascal    void    (*ContentsChangedProc)(WindowPtr w);
  460.     
  461. typedef    pascal    Handle        (*GetFileTextProc)(short vRefNum, long dirID, Str255 fName, Boolean *canDispose);
  462.  
  463. typedef    pascal    Boolean        (*GetFolderProc)(Str255 prompt, short *vRefNum, long *dirID);
  464. typedef    pascal    Boolean        (*OpenSeveralProc)(Boolean sort, short *file_count, StandardFileReply ***files);
  465.     
  466. typedef    pascal    DialogPtr    (*CenterDialogProc)(short dialogID);
  467. typedef    pascal    Boolean        (*StandardFilterProc)(DialogPtr d, EventRecord *event, short *item);
  468. typedef    pascal    void        (*FrameDialogItemProc)(DialogPtr d, short item);
  469.     
  470. typedef    pascal    WindowPtr    (*NewDocumentProc)(void);
  471. typedef    pascal    WindowPtr    (*OpenDocumentProc)(void);
  472.  
  473. typedef    pascal    Handle        (*AllocateProc)(long size, Boolean clear);
  474. typedef    pascal    long        (*FindPatternProc)(char *text, long text_len, long text_offset, 
  475.                                         char *pat, long pat_len,
  476.                                         Boolean case_sensitive);
  477.     
  478. typedef    pascal    void        (*ReportOSErrorProc)(short code);
  479.     
  480. typedef    pascal    void        (*GetPreferenceProc)(ResType prefType, short req_len, void *buffer, short *act_len);
  481. typedef    pascal    void        (*SetPreferenceProc)(ResType prefType, short req_len, void *buffer, short *act_len);
  482.  
  483. typedef    pascal    void        (*StartProgressProc)(Str255 str, long total, Boolean cancel_allowed);
  484. typedef    pascal    Boolean        (*DoProgressProc)(long done);
  485. typedef    pascal    void        (*DoneProgressProc)(void);
  486.     
  487. typedef    pascal    Boolean        (*GetProjectListProc)(FSSpec *spec, short *kind, short *count, ProjectEntry ***entries);
  488. typedef    pascal    Boolean        (*ProjectTextListProc)(FSSpec *spec, Handle *text);
  489.         
  490. typedef    pascal    Boolean        (*PresetUndoProc)(void);
  491. typedef    pascal    void        (*SetUndoProc)(void);
  492.     
  493. typedef    pascal    Boolean        (*OpenFileProc)(FSSpec *spec, WindowPtr *w);
  494.  
  495. typedef pascal    Boolean        (*PrepareUndoProc)(long undo_start, long undo_end,
  496.                                                 long sel_start, long sel_end);
  497. typedef pascal    void        (*CommitUndoProc)(long new_end);
  498.  
  499. typedef pascal    Boolean        (*CreateResultsProc)(Str255 title, short count, Handle results, WindowPtr *w);
  500.  
  501. #define CallGetWindowContents(proc, w) \
  502.     ((proc))((w))
  503.     
  504. #define CallGetSelection(proc, selStart, selEnd, firstChar) \
  505.     ((proc))((selStart), (selEnd), (firstChar))
  506.     
  507. #define CallSetSelection(proc, selStart, selEnd, firstChar) \
  508.     ((proc))((selStart), (selEnd), (firstChar))
  509.     
  510. #define CallGetDocInfo(proc, w, name, vRefNum, dirID) \
  511.     ((proc))((w), (name), (vRefNum), (dirID))
  512.     
  513. #define CallGetModDate(proc, w) \
  514.     ((proc))((w))
  515.     
  516. #define CallCopy(proc) \
  517.     ((proc))()
  518.     
  519. #define CallPaste(proc, h) \
  520.     ((proc))((h))
  521.     
  522. #define CallGetLastLine(proc) \
  523.     ((proc))()
  524.     
  525. #define CallGetLineNumber(proc, sel) \
  526.     ((proc))((sel))
  527.     
  528. #define CallGetLineStart(proc, sel) \
  529.     ((proc))((sel))
  530.     
  531. #define CallGetLineEnd(proc, sel) \
  532.     ((proc))((sel))
  533.  
  534. #define CallGetLinePos(proc, sel) \
  535.     ((proc))((sel))
  536.  
  537. #define CallInsert(proc, text, len) \
  538.     ((proc))((text), (len))
  539.     
  540. #define CallDelete(proc) \
  541.     ((proc))()
  542.     
  543. #define CallSetWindowContents(proc, w, h) \
  544.     ((proc))((w), (h))
  545.     
  546. #define CallContentsChanged(proc, w) \
  547.     ((proc))((w))
  548.     
  549. #define CallGetFileText(proc, vRefNum, dirID, name, canDispose) \
  550.     ((proc))((vRefNum), (dirID), (name), (canDispose))
  551.     
  552. #define CallGetFolder(proc, prompt, vRefNum, dirID) \
  553.     ((proc))((prompt), (vRefNum), (dirID))
  554.     
  555. #define CallOpenSeveral(proc, sort, file_count, files) \
  556.     ((proc))((sort), (file_count), (files))
  557.     
  558. #define CallCenterDialog(proc, dialogID) \
  559.     ((proc))((dialogID))
  560.     
  561. #define CallStandardFilter(proc, d, event, item) \
  562.     ((proc))((d), (event), (item))
  563.  
  564. #define CallFrameDialogItem(proc, d, item) \
  565.     ((proc))((d), (item))
  566.     
  567. #define CallNewDocument(proc) \
  568.     ((proc))()
  569.     
  570. #define CallOpenDocument(proc) \
  571.     ((proc))()
  572.     
  573. #define CallAllocate(proc, size, clear) \
  574.     ((proc))((size), (clear))
  575.     
  576. #define CallFindPattern(proc, text, text_len, text_offset, pat, pat_len, case_sens) \
  577.     ((proc))((text), (text_len), (text_offset), (pat), (pat_len), (case_sens))
  578.                         
  579. #define CallReportOSError(proc, code) \
  580.     ((proc))((code))
  581.     
  582. #define CallGetPreference(proc, prefType, req_len, buffer, act_len) \
  583.     ((proc))((prefType), (req_len), (buffer), (act_len))
  584.     
  585. #define CallSetPreference(proc, prefType, req_len, buffer, act_len) \
  586.     ((proc))((prefType), (req_len), (buffer), (act_len))
  587.  
  588. #define CallStartProgress(proc, str, total, cancel_allowed) \
  589.     ((proc))((str), (total), (cancel_allowed))
  590.     
  591. #define CallDoProgress(proc, done) \
  592.     ((proc))((done))
  593.     
  594. #define CallDoneProgress(proc) \
  595.     ((proc))()
  596.     
  597. #define CallGetProjectList(proc, spec, kind, count, entries) \
  598.     ((proc))((spec), (kind), (count), (entries))
  599.     
  600. #define CallProjectTextList(proc, spec, text) \
  601.     ((proc))((spec), (text))
  602.     
  603. #define CallPresetUndo(proc) \
  604.     ((proc))()
  605.     
  606. #define CallSetUndo(proc) \
  607.     ((proc))()
  608.     
  609. #define CallOpenFile(proc, spec, w) \
  610.     ((proc))((spec), (w))
  611.  
  612. #define CallPrepareUndo(proc, undo_start, undo_end, sel_start, sel_end) \
  613.     ((proc))((undo_start), (undo_end), (sel_start), (sel_end))
  614.     
  615. #define CallCommitUndo(proc, new_end) \
  616.     ((proc))((new_end))
  617.  
  618. #define CallCreateResults(proc, title, count, results, w) \
  619.     ((proc))((title), (count), (results), (w))
  620.     
  621. #endif
  622.  
  623.  
  624. typedef struct
  625. {
  626.     short    version;
  627.     
  628.     //    version 1 callbacks
  629.     
  630.     GetWindowContentsProc    GetWindowContents;
  631.     GetSelectionProc    GetSelection;
  632.     SetSelectionProc    SetSelection;
  633.     GetDocInfoProc    GetDocInfo;
  634.     GetModDateProc    GetModDate;
  635.     CopyProc    Copy;
  636.     PasteProc    Paste;
  637.     
  638.     //    version 2 callbacks
  639.     
  640.     /*    Text-Editing stuff */
  641.     GetLastLineProc    GetLastLine;
  642.     GetLineNumberProc    GetLineNumber;
  643.     GetLineStartProc    GetLineStart;
  644.     GetLineEndProc    GetLineEnd;
  645.     GetLinePosProc    GetLinePos;
  646.     
  647.     InsertProc    Insert;
  648.     DeleteProc    Delete;
  649.     
  650.     /*    Getting and Setting window text */
  651.     SetWindowContentsProc    SetWindowContents;
  652.     ContentsChangedProc    ContentsChanged;
  653.     
  654.     /*    Reading file text */
  655.     GetFileTextProc    GetFileText;
  656.  
  657.     /*    Direct user-interface calls */
  658.     GetFolderProc    GetFolder;
  659.     OpenSeveralProc    OpenSeveral;
  660.     
  661.     CenterDialogProc    CenterDialog;
  662.     StandardFilterProc    StandardFilter;
  663.     FrameDialogItemProc    FrameDialogItem;
  664.     
  665.     NewDocumentProc    NewDocument;
  666.     OpenDocumentProc    OpenDocument;
  667.  
  668.     /*    Utility Routines */
  669.     AllocateProc    Allocate;
  670.     FindPatternProc    FindPattern;
  671.     
  672.     ReportOSErrorProc    ReportOSError;
  673.     
  674.     /*    Preference routines */
  675.     GetPreferenceProc    GetPreference;
  676.     SetPreferenceProc    SetPreference;
  677.  
  678.     /*    Progress routines */
  679.     StartProgressProc    StartProgress;
  680.     DoProgressProc    DoProgress;
  681.     DoneProgressProc    DoneProgress;
  682.     
  683.     //    Version 3 callbacks
  684.     GetProjectListProc    GetProjectList;
  685.     ProjectTextListProc    ProjectTextList;
  686.     
  687.     //    version 4 callbacks
  688.     
  689.     PresetUndoProc    PresetUndo;
  690.     SetUndoProc    SetUndo;
  691.     
  692.     OpenFileProc    OpenFile;
  693.     
  694.     //    version 5 callbacks
  695.     
  696.     PrepareUndoProc    PrepareUndo;
  697.     CommitUndoProc    CommitUndo;
  698.     
  699.     CreateResultsProc    CreateResults;
  700.     
  701. } ExternalCallbackBlock;
  702.  
  703. #if defined(powerc) || defined (__powerc)
  704. #pragma options align=reset
  705. #endif
  706.  
  707. /*    
  708.     'main' for a BBXT is declared:
  709.     
  710. pascal void main(ExternalCallbackBlock *callbacks, WindowPtr w);        [C]
  711.  
  712.     The 'new' calling convention, which passes more information
  713.     and allows scriptability, is this:
  714.     
  715. pascal OSErr main(ExternalCallbackBlock *callbacks, WindowPtr w, long flags, AppleEvent *event, AppleEvent *reply);
  716. */
  717.